#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>

void rotate(int* nums, int numsSize, int k)
{
    int pos = 0;
    int res[100000] = { 0 };
    int i = 0;

    if (k % numsSize == 0)
    {
        return;
    }
    else
    {
        pos = k % numsSize - 1;
    }

    for (i = 0; i <= pos; i++)
    {
        res[pos - i] = nums[numsSize - 1 - i];
    }

    for (i=1; i<=numsSize-pos-1; i++)
    {
        nums[numsSize - i] = nums[numsSize -1 - pos - i];
    }

    for (i = 0; i<=pos; i++)
    {
        nums[i] = res[i];
    }

}

int main()
{
    int nums[] = { 1,2,3,4,5,6,7 };
    int k = 3;
    int sz = sizeof(nums) / sizeof(nums[0]);
    rotate(nums, sz, k);

    for (int i = 0; i < sz; i++)
    {
        printf("%d ", nums[i]);
    }

    return 0;
}